﻿using GLstudent.DAL;
using GLstudent.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GLstudent.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class zhuceController : ControllerBase
    {
        private DAL_zhuce zhuce = new DAL_zhuce();
        /// <summary>
        /// 查询所有数据的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<teacher> chaxun()
        {
            return zhuce.Select();
        }
        /// <summary>
        /// 查询教师编号的方法
        /// </summary>
        /// <param name="t_bianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public teacher chaxunbianhao(int t_bianhao)
        {
            return zhuce.chaxunid(t_bianhao);
        }
        /// <summary>
        /// 无用接口（PS江老师想写的限制，但是并没成功）
        /// </summary>
        /// <param name="bianhao">教师编号</param>
        /// <param name="shenfen">身份</param>
        /// <returns></returns>
        [HttpGet]
        public int chaxunNumber(int bianhao, int shenfen)
        {
            switch (shenfen)
            {
                case 1:
                    var ls = zhuce.chaxunid(bianhao);
                    return ls == null ? 0 : ls.id;
                case 0:
                    var xs = zhuce.chaxunxs(bianhao);
                    return xs == null ? 0 : xs.id;
                default:
                    return -1;
            }
        }
        /// <summary>
        /// 查询教师编号的方法
        /// </summary>
        /// <param name="s_xuehao">学生学号</param>
        /// <returns></returns>
        [HttpGet]
        public zcstudent chaxunxh(int s_xuehao)
        {
            return zhuce.chaxunxs(s_xuehao);
        }
    }
}
